﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace DBtuning
{
    public partial class Param_2 : System.Web.UI.Page
    {
        FetchData fetch = new FetchData();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.Request["id"] == null)
                {
                    this.LabelParam.Text = "Cache_Hit_Ratio_Lib";
                    Session["id"] = "Cache_Hit_Ratio_Lib";
                }
                else
                {
                    this.LabelParam.Text = this.Request["id"];
                    Session["id"] = this.Request["id"];
                }
            }
        }

        protected void view_Click(object sender, EventArgs e)
        {
            DateTime now = DateTime.Now;
            DateTime pre = now.AddDays(-1);
            int interval = Int16.Parse(DropDownList1.Text.Substring(0, DropDownList1.Text.Length - 3));
            Session["interval"] = interval;
            DataTable dt = new DataTable();
            dt = fetch.GetDetails(this.LabelParam.Text, interval, pre, now);
            Session["Data"] = dt;
            GridView_Param.DataSource = dt;
            GridView_Param.DataBind();
        }

        protected void LBtnBack_Click(object sender, EventArgs e)
        {
            this.Response.Redirect("Param_1.aspx");
        }

        protected void GridView_Param_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (Session["Data"] == null)
                return;
            GridView_Param.DataSource = (DataTable)Session["Data"];
            GridView_Param.PageIndex = e.NewPageIndex;
            GridView_Param.DataBind();
        }
    }
}
